<?php
/** costumer_transfer.php
 * Project name: project_name
 * Created on: 08.12.2011
 * Author: Matias Thomsen
 * 
 * Tabellen zur navigation von Zentrale bis zur auswähl einer Geschäftsstelle
 */
//-----VARS-------------
    $staff = $_SESSION['userID']; //employee logged in
    $gstelle = $_SESSION['gstelleId']; //employees' workstation
//-----VARS END---------
    
if ( isset($_GET['zentrale']) ){
    $query = "SELECT * FROM `bezirk` WHERE `zentraleId` = ".$_GET['zentrale']."";
    $action = $_SERVER['PHP_SELF']."?page=contact-gstelle&bezirk=";
}elseif( $_GET['bezirk'] ){
    $query = "SELECT * FROM `filiale` WHERE `bezirkId` = ".$_GET['bezirk']."";
    $action = $_SERVER['PHP_SELF']."?page=contact-gstelle&filiale=";
}elseif( $_GET['filiale'] ){
    $query = "SELECT * FROM `gstelle` WHERE `filialeId` = ".$_GET['filiale']." AND `idGstelle` <> '$gstelle'";
    $action = $_SERVER['PHP_SELF']."?page=contact-transfer&neue-stelle=";
}else{
    $query = "SELECT * FROM `zentrale`";
    $action = $_SERVER['PHP_SELF']."?page=contact-gstelle&zentrale=";
}

$stm = $sql->prepare($query);
$result = $stm->execute();

$fetch = $stm->fetchAll();
?>
<div>
<table id="js_table_layout" style="width: 100%">
    <thead>
        <tr>
            <th style="text-align: left; text-indent: 5px;">ID</th>
            <th style="text-align: left; text-indent: 5px;">Bezeichnung</th>
            <th style="text-align: left; text-indent: 5px;">Kürzel</th>
            <th>&nbsp;</th>
        </tr>
    </thead>
    <tbody>
        <?php
        foreach ( $fetch as $row ){
        ?>
        <tr>
            <td style="width: 10%; text-indent: 10px;"><?= utf8_decode($row[0]) ?></td>
            <td style="width: 65%; text-indent: 10px;"><?= utf8_decode($row[1]) ?></td>
            <td style="width: 10%; text-indent: 10px;"><?= utf8_decode($row[2]) ?></td>
            <td style="width: 15%; text-align: center;"><a href="<?= $action.$row[0] ?>">auswählen</a></td>
        </tr>
        <?php
        }
        ?>
        
    </tbody>
</table>
</div>
<script lang="JavaScript">
        $(document).ready(function() {
            $('#js_table_layout').dataTable();
        } );
</script>